<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Farmacias Santa Martha</title>
        <h:outputStylesheet library="css" name="main.css" />
        <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'/>
        <link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'/>
        <script type="text/javascript" src="scripts/shCore.js"></script>
        <script type="text/javascript" src="scripts/shBrushJScript.js"></script>
        <link type="text/css" rel="stylesheet" href="styles/shCoreDefault.css"/>
        <script type="text/javascript">SyntaxHighlighter.all();</script>
    </h:head>
    <h:body>
        <h:form>
            <div style="width: 100%; background-color: white;">
                <table border="0" width="100%">
                    <tr>
                        <td rowspan="2" style="color: crimson; font-family: 'Oswald', sans-serif; font-size: 42px; display:table-cell; vertical-align: middle; padding-left: 8px;" valign="middle">FARMACIAS SANTA MARTHA</td>
                        <td style="font-family: 'Open Sans Condensed', sans-serif; font-size: 18px; display:table-cell; vertical-align: middle; padding-right: 8px; font-weight: bold;" valign="middle" align="right">#{usuarioMB.ruc}&nbsp;-&nbsp;#{usuarioMB.razonSocial}</td>
                    </tr>
                    <tr>
                        <td style="font-family: 'Open Sans Condensed', sans-serif; font-size: 18px; display:table-cell; vertical-align: middle; padding-right: 8px;" valign="middle" align="right">
                            <!--                            <h:form>-->
                            <h:commandLink value="Cerrar sesión" action="#{usuarioMB.cerrarSesion}"/>
                            <!--                            </h:form>-->
                        </td>
                    </tr>
                </table>
            </div>
        </h:form>
        <h:form id="form">
            <p:dataTable id="basicDT" var="comp" value="#{comprobanteMB.lstComprobantes}" 
                         rows="20"
                         paginator="true"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="15,20,25">
                <f:facet name="header">
                    Comprobantes
                </f:facet>
                <p:column headerText="Tipo de documento" style="width:100px;">
                    <h:outputText value="#{comp.tipoDocumento.codigo}" />
                </p:column>
                <p:column headerText="Clave de acceso">
                    <h:outputText value="#{comp.claveAcceso}" />
                </p:column>
                <p:column headerText="Número de autorización">
                    <h:outputText value="#{comp.numeroAutorizacion}" />
                </p:column>
                <p:column headerText="Fecha de autorización" style="width:150px;">
                    <h:outputText value="#{comp.fechaAutorizacion}" />
                </p:column>
                <p:column style="width:32px; text-align: center">
                    <p:commandButton update=":form:carDetail" oncomplete="PF('carDialog').show()" icon="ui-icon-search" title="XML">
                        <f:setPropertyActionListener value="#{comp}" target="#{comprobanteMB.comprobanteSeleccionado}" />
                    </p:commandButton>
                </p:column>
                <p:column style="width:100px; text-align: center;">
                    <p:commandButton value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop);" icon="ui-icon-arrowthick-1-s">
                        <f:setPropertyActionListener value="#{comp}" target="#{comprobanteMB.comprobanteSeleccionado}" />
                        <p:fileDownload value="#{comprobanteMB.file}" />
                    </p:commandButton>
                </p:column>
            </p:dataTable>

            <p:dialog header="Comprobante" widgetVar="carDialog" modal="true" 
                      showEffect="fade" hideEffect="fade" resizable="false"
                      width="690" height="615" style="margin: 0px; padding: 0px;">
                <p:outputPanel id="carDetail" style="text-align:center; margin: 0px; padding: 0px;">
                    <p:panelGrid  columns="2" rendered="#{not empty comprobanteMB.comprobanteSeleccionado}" columnClasses="label,value">
                        <p:media value="#{mediaManager.stream}" width="640" height="600px" player="pdf">
                            <f:param name="pathPdf" value="#{comprobanteMB.comprobanteSeleccionado.pathPdf}" />
                        </p:media>
                    </p:panelGrid>
                </p:outputPanel>
            </p:dialog>

        </h:form>
    </h:body>
</html>